<?php

namespace App;

namespace App\Model;

use Hyperf\DbConnection\Db;
use Hyperf\Redis\Redis;
use Util\Common;

/**
 * App\Station
 *
 * @property int $id
 * @property int $distributor_id 分销商
 * @property array $images 图片些
 * @property string $name 名称
 * @property string|null $description 简介
 * @property string $address 位置
 * @property string $lat 位置
 * @property string $lng 位置
 * @property int $discount 折扣 100为不打折
 * @property string|null $remark 备注
 * @property int $is_active 是否可用
 */
class Station extends Model
{
    //
    public bool $timestamps = true;

    protected ?string $table = 'stations';

    protected array $fillable = [
        'name', 'address', 'lat', 'lng', 'images', 'distributor_id', 'description',
        'discount', 'remark', 'charge_id', 'is_return_fee', 'is_active',
        'province_id', 'city_id', 'area_id', 'province_name', 'city_name', 'area_name'
    ];

    protected array $casts = [
        'images' => 'json'
    ];

    public function distributors()
    {
        return $this->belongsTo(Distributors::class, 'id', 'distributor_id');
    }

    /**
     * @return \Hyperf\Database\Model\Relations\HasMany
     */
    public function devices()
    {
        return $this->hasMany(Device::class, 'station_id', 'id');
    }


}
